#!/usr/bin/env python
# -*- coding: utf-8 -*-

#wsgiapp_test.py

import os, sys
sys.path.append(os.path.split(os.path.abspath(__file__))[0])

from wsgiapp import BaseWsgiApp

class MyApp(BaseWsgiApp):

    routes = (
        (r"^test$", "index"),
        (r"^hi/(?P<who>[a-zA-Z]+)/(?P<adj>[a-zA-Z]+)?$", "greet"),
    )

    def index(self):
        self.start_response('200 OK', [('Content-Type', 'text-plain')])
        return ['Hello, World!']

    def greet(self, adj = "Silly ", who = "Nobody"):
        self.start_response('200 OK', [('Content-Type', 'text-plain')])
        return ["Hi, ", adj, " ", who, "!"]

#and to run it:
if __name__ == '__main__':
    MyApp.run(port=8086, host="127.0.0.1")
